package top.xia17.plugins.fast.quartz.core;

import lombok.Data;
import org.springframework.data.annotation.Id;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 任务执行日志
 *
 * @author Zheng Jie
 * @date 2019-01-07
 */
@Data
public class QuartzLogInfo implements Serializable {

    public QuartzLogInfo() {
        this.createTime = LocalDateTime.now();
    }

    @Id
    private Long id;

    /**
     * 任务名称
     */
    private String jobName;

    /**
     * bean名称
     */
    private String beanName;

    /**
     * 方法名称
     */
    private String methodName;

    /**
     * 参数
     */
    private String params;

    /**
     * cron表达式
     */
    private String cron;

    /**
     * 状态
     */
    private Boolean isSuccess;

    /**
     * 异常详情
     */
    private String exceptionDetail;

    /**
     * 执行耗时
     */
    private Long time;

    /**
     * 创建时间
     */
    private LocalDateTime createTime;


    public void setQuartzJob(QuartzJobInfo jobInfo) {
        this.jobName = jobInfo.getJobName();
        this.beanName = jobInfo.getBeanName();
        this.methodName = jobInfo.getMethodName();
        this.params = jobInfo.getParam();
        this.cron = jobInfo.getCron();
    }

}
